<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Bishop news helper</title>
    <script src="/static/js/ksmain.js"></script>
    <link rel="stylesheet" type="text/css" href="/static/css/bootstrap.css">
    <link rel="icon" type="image/png" href="/static/img/favicon.ico" />
</head>
<script type="text/javascript">
function admin_or_not_admin(){
    var pas='pimpa'
    var pasword=prompt('Введи пароль, броутишка. Не гей ли ты?');
    if (pasword != pas){
        window.location="http://www.gay.ru"
    }
}
admin_or_not_admin()

</script>
<body>
    <div class="navbar navbar-inverse navbar-static-top">
      <div class="navbar-inner">
        <div class="container">
          <a class="btn btn-default navbar-btn btn-default" data-toggle="collapse" data-target=".navbar-collapse">
          <a class="navbar-brand">Bishop news helper</a>
          <div class="navbar-collapse collapse">
            <p class="navbar-text pull-right">
            </p>
          </div>
        </div>
       </div>
    </div>
<script type="text/javascript">
function news(el,command){
    var form=document.getElementById('form2');
    var id
    var in_put=document.getElementById('id_inp');
    var block=document.getElementById('block2');
    var button=document.getElementById('button2');
    var req=new XMLHttpRequest();
    button.style.display='block'
    var help_button=document.getElementById('button3');
    if (command=="get"){
        var id=prompt('id - сообщения',' ');
        help_button.style.display='block'
        block.style.display='block'
        in_put.style.display='block'
        in_put.value=id
        var url = '/duhastlider/news/'+command+'/'+id
        req.open('GET', url , true);
        req.onreadystatechange = function() {
        if (req.readyState != 4) return;
            block.innerHTML=req.responseText
        }
        req.send()
        }
    if (command=="delete"){
             id=in_put.value
             var url = '/duhastlider/news/'+command+'/'+id
             req.open('GET', url , true);
             req.onreadystatechange = function() {
             if (req.readyState != 4) return;
                block.innerHTML="Удалена"
             }
             req.send()
         }
    if (command=="change"){
             id=in_put.value
             var url = '/duhastlider/news/'+command;
             var newblock=document.getElementById('block2');
             var post_body="msg="+newblock.value+"&id="+id;
             req.open('POST', url , true);
             req.onreadystatechange = function() {
             if (req.readyState != 4) return;
                window.location="/duhastlider"
                 }
             req.send(post_body)
             }
    if (command=="add"){
            block.style.display='block'
            in_put.style.display='block'
            var url = '/duhastlider/news/'+command
            var post_body="msg="+newblock.value+"&id="+id;
            req.open('POST', url , true);
            req.onreadystatechange = function() {
            if (req.readyState != 4) return;
                window.location="/duhastlider"
            }
            req.send(post_body)
        }
 }
</script>
<script type="text/javascript">
function contentedit(el,name){
    var form=document.getElementById('form1');
    var block=document.getElementById('block');
    var button=document.getElementById('button');
    block.style.display='block'
    button.style.display='block'
    form.action='/duhastlider/command/action/'+name
    var req=new XMLHttpRequest();
    req.open('GET', '/duhastlider/command/'+name, true);
    req.onreadystatechange = function() {
        if (req.readyState != 4) return;
        block.innerHTML=req.responseText
    }
    req.send()
}
</script>


  <div class="container">
    <a href="/main"><button class="btn btn-default btn-sm" type="button">главная</button></a>
     <div class="jumbotron">
        <div class="row">
           <div class="col-md-2">
              <div class="well sidebar-nav">
                 <ul class="nav nav-list">
                   <li class="nav-header"></li>
                    <hr>
                   <li><button onclick=news(this,"add") class="btn btn-default btn-sm" type="button">Новости</button></li>
                 </ul>
                                 <ul class="nav nav-list">
                                   <li class="nav-header"></li>
                                   <hr>
                                   <li><a href="/main">Выборка</a></li>
                                   <li><button   onclick=contentedit(this,"faq") class="btn btn-default btn-sm" type="button">FAQ</button></li>
                                   <li><button   onclick=contentedit(this,"help") class="btn btn-default btn-sm" type="button">Помощь</button></li>
                                   <li><button   onclick=contentedit(this,"conn") class="btn btn-default btn-sm" type="button">Обратная связь</button></li>
                                 </ul>
              </div>

           </div>

            <div class="col-md-9">
                <div class="jumbotron">
                            <form enctype="text/plain" id="form1" action=" " method="POST" accept-charset="utf-8" >
                                    <textarea id="block" name="comment" style="width: 90%; display: none;"></textarea>
                                            <div class="col-md-7" id="button" style="display: none;">
                                                <button   type="submit" class="btn btn-default btn-sm" type="button">Редактировать</button>
                                            </div>
                            </form>
                            <form enctype="text/plain" id="form2" action="/duhastlider/news/add" method="POST" accept-charset="utf-8" >
                                    <textarea onchange="this.value" id="block2" name="text" style="width: 90%; height:350px; display: none;"></textarea>
                                          <div class="row">
                                            <div class="col-md-3" id="button2" style="display: none;">
                                                <button  type="submit"  class="btn btn-default btn-sm" type="button">Добавить</button>
                                                <button  onclick=news(this,"get") class="btn btn-default btn-sm" type="button">Загрузить</button>
                                            </div>
                                            <div class="col-md-5" id="button3" style="display: none;" >
                                                <button  onclick=news(this,"change") class="btn btn-default btn-sm" type="button">Изменить</button>
                                                <div id="id_inp" style="display: None;" name="id" value="" ></div>
                                                <button  onclick=news(this,"delete") class="btn btn-default btn btn-default-danger" type="button">Удалить</button>

                                            </div>
                                          <div>
                            </form>
                </div>
            </div>
        </div>
     </div>
  </div>

</body>
</html>